import tseslint from '@electron-toolkit/eslint-config-ts'
import eslintConfigPrettier from '@electron-toolkit/eslint-config-prettier'
import eslintPluginVue from 'eslint-plugin-vue'
import vueParser from 'vue-eslint-parser'

import { importPluginConfig } from './config/eslint/import.mjs'
import { javascriptConfig } from './config/eslint//javascript.mjs'
import { ignores } from './config/eslint//ignores.mjs'
/** @type {import('eslint').Linter.FlatConfig[]} */
export default [
  {
    ignores: await ignores()
  },

  // 导入路径检测配置
  ...importPluginConfig(),
  // JavaScript 推荐配置
  ...(await javascriptConfig()),

  // TypeScript 推荐配置
  // ...tseslint.configs.recommended,

  // Vue 推荐配置
  ...eslintPluginVue.configs['flat/recommended'],

  // Vue 文件解析设置
  {
    files: ['**/*.vue'],
    languageOptions: {
      parser: vueParser,
      parserOptions: {
        ecmaFeatures: {
          jsx: true
        },
        extraFileExtensions: ['.vue'],
        parser: tseslint.parser
      }
    }
  },

  // 自定义规则
  {
    files: ['**/*.{ts,mts,tsx,vue}'],
    rules: {
      'vue/require-default-prop': 'off',
      'vue/multi-word-component-names': 'off',
      'no-console': ['error', { allow: ['warn', 'error'] }],
      'vue/block-lang': [
        'error',
        {
          script: {
            lang: 'ts'
          }
        }
      ]
    }
  },

  // prettier 配置
  eslintConfigPrettier
]
